﻿using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using BlackCoffeeRESTful.Configs;
using BCDto.OA.Attendance.AttendanceRemedyRules;
using BCService.OA.Attendance.AttendanceRemedyRules;

namespace BlackCoffeeRESTful.Controllers.Management.OA.Attendance
{
    /// <summary>
    /// 考勤补卡规则
    /// </summary> 
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/OA/[controller]")]
    public class AttendanceRemedyRulesController : ManagementBaseController
    {
        private readonly IAttendanceRemedyRulesService remedyRulesService;

        public AttendanceRemedyRulesController(IAttendanceRemedyRulesService remedyRulesService)
        {
            this.remedyRulesService = remedyRulesService;
        }

        #region 创建补卡规则
        /// <summary>
        /// 创建补卡规则
        /// </summary>
        /// <response code="201">补卡规则创建成功</response>
        /// <returns></returns>
        [HttpPost]
        [Log("创建补卡规则")]
        [ProducesResponseType(typeof(AttendanceRemedyRulesDto), 201)]
        public IActionResult Post([FromBody]AttendanceRemedyRulesRequestDto dto)
        {
            var result = this.remedyRulesService.Create(this.Admin, dto);
            return Created(string.Format("api/v1/sim/OA/AttendanceRemedyRules/{0}", result.RemedyRuleId), result);
        }

        #endregion

        #region 补卡规则修改
        /// <summary>
        /// 修改补卡规则信息
        /// </summary>
        /// <param name="remedyRuleId">指定的补卡规则Id</param>
        /// <param name="dto">补卡规则修改信息</param>
        /// <returns></returns>
        /// <response code="200">修改后的补卡规则信息。</response>
        [HttpPut("{remedy_rule_id}")]
        [Log("修改补卡规则信息")]
        [ProducesResponseType(typeof(AttendanceRemedyRulesDto), 200)]
        public IActionResult Put([FromRoute(Name = "remedy_rule_id")] long remedyRuleId, [FromBody]AttendanceRemedyRulesRequestDto dto)
        {
            return this.Ok(this.remedyRulesService.Update(this.Admin, remedyRuleId, dto));
        }

        #endregion

        #region 补卡规则查询

        #endregion

        /// <summary>
        /// 考勤补卡规则列表
        /// </summary>
        /// <response code="200">数据查询成功。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(List<AttendanceRemedyRulesDto>), 200)]
        public IActionResult Query()
        {
            var data = remedyRulesService.GetList();
            return Ok(data);
        }
    }
}
